package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TShebzt;
import com.ruoyi.system.service.ITShebztService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 设备状态中间 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/tShebzt")
public class TShebztController extends BaseController
{
    private String prefix = "system/tShebzt";
	
	@Autowired
	private ITShebztService tShebztService;
	
	@RequiresPermissions("system:tShebzt:view")
	@GetMapping()
	public String tShebzt()
	{
	    return prefix + "/tShebzt";
	}
	
	/**
	 * 查询设备状态中间列表
	 */
	@RequiresPermissions("system:tShebzt:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TShebzt tShebzt)
	{
		startPage();
        List<TShebzt> list = tShebztService.selectTShebztList(tShebzt);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出设备状态中间列表
	 */
	@RequiresPermissions("system:tShebzt:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TShebzt tShebzt)
    {
    	List<TShebzt> list = tShebztService.selectTShebztList(tShebzt);
        ExcelUtil<TShebzt> util = new ExcelUtil<TShebzt>(TShebzt.class);
        return util.exportExcel(list, "tShebzt");
    }
	
	/**
	 * 新增设备状态中间
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存设备状态中间
	 */
	@RequiresPermissions("system:tShebzt:add")
	@Log(title = "设备状态中间", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TShebzt tShebzt)
	{		
		return toAjax(tShebztService.insertTShebzt(tShebzt));
	}

	/**
	 * 修改设备状态中间
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		TShebzt tShebzt = tShebztService.selectTShebztById(id);
		mmap.put("tShebzt", tShebzt);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存设备状态中间
	 */
	@RequiresPermissions("system:tShebzt:edit")
	@Log(title = "设备状态中间", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TShebzt tShebzt)
	{		
		return toAjax(tShebztService.updateTShebzt(tShebzt));
	}
	
	/**
	 * 删除设备状态中间
	 */
	@RequiresPermissions("system:tShebzt:remove")
	@Log(title = "设备状态中间", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tShebztService.deleteTShebztByIds(ids));
	}
	
}
